﻿using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.IBusiness.DTO;
using Coldairarrow.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Threading.Tasks;

namespace Coldairarrow.Business.PB
{
    public partial interface IPB_OutsourcingBillBusiness
    {
        Task<PageResult<PB_OutsourcingBillViewDTO>> GetDataListAsync(PageInput<PB_OutsourcingBilSelectDTO> input);
        Task<PB_ProductionDataListDTO> GetTheDataAsync(string id);
        Task AddDataAsync(PB_OutsourcingBillDTO data);
        Task UpdateDataAsync(PB_OutsourcingBillDTO data);
        Task DeleteDataAsync(List<string> ids);
        Task Approve(AuditDTO audit);
        Task Reject(AuditDTO audit);
        Task Signin(AuditDTO audit);
        Task Start(string Id);
        Task<PB_ProductionDataListDTO> GetTheDataInfoPrintAsync(string id);
        Task<PB_OutsourcingBillInfo> GetOutsourcingBillInfo(string id);
        /// <summary>
        /// 外包回货签收明细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PB_ProductionDataListDTO> GetTheDataInfoSignAsync(string id);

        /// <summary>
        /// 外包回货签收
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task UpdateDataAsync(PB_ProductionDataListDTO data);
        #region PDA 出库
        Task<PB_OutsourcingBillDetail> GetPDADataListAsync(string outsourqrcode);

        Task<bool> GetLocationProjectTruOrFalseAsync(string packqrcode, string outsourqrcode);
        Task UpdatePDAOutsourcingUpData(OutsourcingData data);
        Task<PB_DispatchDetailPDANumberDTO> GetMaterialDataAsync(string packqrcode, string localqrcode);
        Task DeletePDAOutsourcingUpDataAsync(string outsourqrcode, string packqrocde, double nums);
        Task SubmitPDAOutsourcingUpDataAsync(string outsourqrcode);
        Task<List<PB_UnLoadListDataDTO>> GetOutsourcingUpDetailListDataAsync(string outsourqrcode);
        Task CancelStockUpAsync(string outsourqrcode);
        /// <summary>
        /// 扫描包获取该流转卡
        /// </summary>
        /// <param name="packqrcode">包二维码</param>
        /// <returns></returns>
        Task<PB_CirculationBillDTO> GetPackDataListAsync(string packqrcode);
        /// <summary>
        /// 外包签收
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task RejectDataAsync(PB_OutsourcingBillDTO data);




        #endregion

        #region  建立外包单获取物料信息

        /// <summary>
        /// 获取物料信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<OutBillMaterialDTO>> GetOutBillMaterialListAsync(PageInput<OutBillMaterialConditionDTO> input);

        #endregion

        #region  外包单

        #region  PDA外包单领料

        /// <summary>
        /// PDA出库选择物料信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<OutBillMaterialReceiveDTO>> GetOutBillMaterialReceiveListAsync(PageInput<OutBillMaterialReceiveConditionDTO> input);

        /// <summary>
        /// PDA物料出库保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveOutBillMaterialReceiveDataAsync(OutBillMaterialDataDTO data);

        /// <summary>
        /// 获取外包单已出库明细
        /// </summary>
        /// <param name="OutBillQrCode">外包单二维码</param>
        /// <returns></returns>
        Task<List<OutsourcingBillUpListDTO>> GetOutsourcingBillUpListAsync(string OutBillQrCode);

        /// <summary>
        /// 移除出库明细
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task DeleteOutsourcingBillUpListAsync(OutsourcingBillUpListDTO data);

        /// <summary>
        /// 提交外包单出库信息
        /// </summary>
        /// <param name="OutBillQrCode">外包单二维码</param>
        /// <returns></returns>
        Task SubmitOutsourcingBillUpListAsync(string OutBillQrCode);

        #endregion

        #region  流转卡生成外包单

        /// <summary>
        /// 获取流转卡物料信息
        /// </summary>
        /// <param name="CirBillQrCode">流转卡二维码</param>
        /// <returns></returns>
        Task<OutBillCirculationMaterialDTO> GetOutBillCirculationMaterialAsync(string CirBillQrCode);

        /// <summary>
        /// 保存流转卡生成外包单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveOutBillMaterialAsync(CirBillSaveOutBill data);

        #endregion

        #region 外包单装车

        /// <summary>
        /// 外包装车扫描外包单
        /// </summary>
        /// <param name="OutBillQrCode">外包单二维码</param>
        /// <param name="BillId">派车单Id</param>
        /// <returns></returns>
        Task<PB_OutsourcingBill> GetOutsourcingBillDataAsync(string OutBillQrCode, string BillId);

        /// <summary>
        /// 获取派车单对应的外包单需要装车的物料
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<TranBillOutMaterialDTO>> GetTranBillOutMaterialListAsync(PageInput<TranBillOutMaterialConditionDTO> input);

        /// <summary>
        /// 外包单装车保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveTranBillOutMaterialAsync(TranBillOutMaterialDTO data);

        /// <summary>
        /// 获取外包单装车明细
        /// </summary>
        /// <param name="BillId">派车单Id</param>
        /// <returns></returns>
        Task<List<OutBillTransportBillDetailDTO>> GetOutBillTransportBillDetailAsync(string BillId);

        /// <summary>
        /// 提交装车信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SubmitOutBillTransportAsync(PB_TransportBillImgDTO data);

        /// <summary>
        /// 移除装车明细
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task DeleteOutBillTransportBillDetailAsync(OutBillTransportBillDetailDTO data);

        #endregion

        #region 外包单回货

        /// <summary>
        /// 获取外包单位下未完全回货的外包单
        /// </summary>
        /// <param name="OutsourcingCompanyId">外包单位Id</param>
        /// <returns></returns>
        Task<List<PB_OutsourcingBill>> GetOutsourcingBillReturnAsync(string OutsourcingCompanyId);

        /// <summary>
        /// 获取外包回派车单信息
        /// </summary>
        /// <returns></returns>
        Task<List<PB_TransportBill>> GetTransportBillOutReturnAsync();

        /// <summary>
        /// 获取外包单的明细信息
        /// </summary>
        /// <param name="OutBillId">外包单Id</param>
        /// <returns></returns>
        Task<List<OutMaterialReturnDTO>> GetOutMaterialReturnListAsync(string OutBillId);

        /// <summary>
        /// 外包单保存
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveOutMaterialReturnAsync(OutMaterialReturnDataDTO data);

        /// <summary>
        /// 外包回货列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<PB_OutsourcingBillViewDTO>> GetDataReturnListAsync(PageInput<PB_OutsourcingBilSelectDTO> input);

        /// <summary>
        /// 获取外包单的回货明细
        /// </summary>
        /// <param name="OutBillId">外包单Id</param>
        /// <returns></returns>
        Task<List<OutsourcingBillReturnDetailDTO>> GetOutsourcingBillReturnDetailAsync(string OutBillId);

        #endregion

        #endregion

    }

    public class OutsourcingData
    {
        /// <summary>
        /// 包码/物料码
        /// </summary>
        public string packqrcode { get; set; }

        /// <summary>
        /// 外协单
        /// </summary>
        public string outsourqrcode { get; set; }

        /// <summary>
        /// 物料数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 货位二维码
        /// </summary>
        public string localqrcode { get; set; }

    }


    #region  建立外包单获取物料信息

    /// <summary>
    /// 获取物料信息
    /// </summary>
    public class OutBillMaterialDTO
    {
        [Key, Column(Order = 1)]
        public string Id { get; set; }

        /// <summary>
        /// 物料信息
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public double? Price { get; set; }

        /// <summary>
        /// 理论重量
        /// </summary>
        public double? Weight { get; set; }

        /// <summary>
        /// 物料使用状态(0未启用 ，1启用)
        /// </summary>
        public Boolean? UsageStatus { get; set; }

        /// <summary>
        /// 库存数量
        /// </summary>
        public double? SacnNums { get; set; }

        /// <summary>
        /// 任务单生产数量
        /// </summary>
        public double? Productionquantity { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 仓库名称
        /// </summary>
        public string StorName { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }

        /// <summary>
        /// 货位
        /// </summary>
        public string LocalName { get; set; }

        /// <summary>
        /// 任务单Id
        /// </summary>
        public string OrderId { get; set; }

    }

    public class OutBillMaterialConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 任务单Id
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

    }

    #endregion

    #region  外包单

    #region  PDA外包单领料

    /// <summary>
    /// PDA选择物料
    /// </summary>
    public class OutBillMaterialReceiveDTO
    {

        public string Id { get; set; }

        /// <summary>
        /// 外包单Id
        /// </summary>
        public string OutBillId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }

        /// <summary>
        /// 库存数量
        /// </summary>
        public double? ScanNum { get; set; }

        /// <summary>
        /// 外包数量
        /// </summary>
        public double? OutBillNums { get; set; }

        /// <summary>
        /// 剩余出库数量
        /// </summary>
        public double? SurplusNums { get; set; }

        /// <summary>
        /// 本次出库数量
        /// </summary>
        public double? Nums { get; set; }

    }

    /// <summary>
    /// PDA选择物料搜索条件
    /// </summary>
    public class OutBillMaterialReceiveConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 外包单二维码
        /// </summary>
        public string OutBillQrCode { get; set; }

        /// <summary>
        /// 货位二维码
        /// </summary>
        public string LocalQrCode { get; set; }

    }

    /// <summary>
    /// PDA物料出库保存
    /// </summary>
    public class OutBillMaterialDataDTO
    {
        /// <summary>
        /// 外包单二维码
        /// </summary>
        public string OutBillQrCode { get; set; }

        /// <summary>
        /// 货位二维码
        /// </summary>
        public string LocalQrCode { get; set; }

        public OutBillMaterialReceiveDTO OutBillMaterialReceive { get; set; }

    }

    /// <summary>
    /// 外包单已出库物料明细
    /// </summary>
    public class OutsourcingBillUpListDTO : PB_OutsourcingBillUpList
    {
        /// <summary>
        /// 货位名称
        /// </summary>
        public string LocalName { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

    }

    /// <summary>
    /// 获取外包单物料出库信息
    /// </summary>
    public class OutsourcingMaterialDTO : PB_OutsourcingBillUpList
    {
        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 物料单价
        /// </summary>
        public double? Price { get; set; }

    }


    #endregion

    #region 流转卡生成外包单

    /// <summary>
    /// 获取流转卡物料信息
    /// </summary>
    public class OutBillCirculationMaterialDTO : PB_CirculationBill
    {

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 项目Id
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 理论重量
        /// </summary>
        public double? Weight { get; set; }

    }

    /// <summary>
    /// 保存流转单生成外包单
    /// </summary>
    public class CirBillSaveOutBill
    {
        /// <summary>
        /// 外协单位Id
        /// </summary>
        public string OutsourcingCompanyId { get; set; }

        /// <summary>
        /// 外协单位名称
        /// </summary>
        public string OutsourcingCompanyName { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public double? Price { get; set; }

        /// <summary>
        /// 外协日期
        /// </summary>
        public DateTime? OutsourcingDate { get; set; }

        /// <summary>
        /// 预计完工日期
        /// </summary>
        public DateTime? ExpectedDate { get; set; }

        /// <summary>
        /// 工序Id
        /// </summary>
        public string SubId { get; set; }

        /// <summary>
        /// 流转单集合
        /// </summary>
        public List<OutBillCirculationMaterialDTO> OutBillMaterial { get; set; }

    }

    #endregion

    #region 外包单装车

    /// <summary>
    /// 外包单装车物料信息
    /// </summary>
    public class TranBillOutMaterialDTO
    {

        /// <summary>
        /// 派车单Id
        /// </summary>
        public string BillId { get; set; }

        /// <summary>
        /// 外包单Id
        /// </summary>
        public string OutBillId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public double? ReadyNums { get; set; }

        /// <summary>
        /// 已装车数量
        /// </summary>
        public double? PackNums { get; set; }

        /// <summary>
        /// 剩余装车数量
        /// </summary>
        public double? SurplusNums { get; set; }

        /// <summary>
        /// 本次装车数量
        /// </summary>
        public double? Nums { get; set; }

    }

    public class TranBillOutMaterialConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 派车单Id
        /// </summary>
        public string BillId { get; set; }

        /// <summary>
        /// 外包单二维码
        /// </summary>
        public string OutBillQrCode { get; set; }
    }

    /// <summary>
    /// 外包单装车明细
    /// </summary>
    public class OutBillTransportBillDetailDTO : PB_TransportBillDetail
    {
        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 外包单名称
        /// </summary>
        public string OutName { get; set; }

    }


    #endregion

    #region 外包单回货

    /// <summary>
    /// 外包单物料信息
    /// </summary>
    public class OutMaterialReturnDTO
    {
        /// <summary>
        /// 外包单Id
        /// </summary>
        public string OutBillId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 物料单价
        /// </summary>
        public double? Price { get; set; }

        /// <summary>
        /// 理论重量
        /// </summary>
        public double? Weight { get; set; }

        /// <summary>
        /// 外包单数量
        /// </summary>
        public double? QtyNums { get; set; }

        /// <summary>
        /// 外包单已回货数量
        /// </summary>
        public double? ReturnNums { get; set; }

        /// <summary>
        /// 外包单剩余回货数量
        /// </summary>
        public double? SurplusNums { get; set; }

        /// <summary>
        /// 本次回货数量
        /// </summary>
        public double? Nums { get; set; }

    }

    /// <summary>
    /// 回货保存
    /// </summary>
    public class OutMaterialReturnDataDTO
    {
        /// <summary>
        /// 派车单Id
        /// </summary>
        public string BillId { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 派车单Id
        /// </summary>
        public List<OutMaterialReturnDTO> OutMaterialReturn { get; set; }

    }

    /// <summary>
    /// 外包单回货明细
    /// </summary>
    public class OutsourcingBillReturnDetailDTO : PB_OutsourcingBillReturnDetail
    {
        /// <summary>
        /// 车牌号
        /// </summary>
        public string PlateNO { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

    }

    #endregion

    #endregion

}